package com.ruoyi.job.task;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.auto.api.RemoteAutoPublishProductService;
import com.ruoyi.auto.api.domain.ErpAutoPulishProductProjectTask;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.SpringUtils;
import com.ruoyi.gather.api.domain.dto.AeAutoProductDto;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

import static jodd.util.ThreadUtil.sleep;

/**
 * 自动上品计划定时任务调度
 *
 * @Author: j.zh
 * @Date: 2024/3/18
 * @Version: 1.0
 */
@Component("autoPublishTask")
public class AutoPublishProductTask {

    @Resource
    private RemoteAutoPublishProductService remoteAutoPublishProductService;

    /**
     * 执行自动化任务
     */
    public void AutoPublishProduct() {
        System.out.println("开始执行任务（"+new Date()+"）");
        remoteAutoPublishProductService.runPublishProductTask("null");
    }

    /**
     * 启动自动化执行计划 创建任务
     */
    public void RunAutoPublishProject() {
        System.out.println("开始创建执行计划（"+new Date()+")");
        remoteAutoPublishProductService.runAutoPublishProject();
    }

    /**
     * 重启执行计划
     */
    public void RestartPublishProductProjectJob() {
        System.out.println("开始重启执行任务（"+new Date()+")");
        remoteAutoPublishProductService.restartPublishProductProjectJob();
    }

    /**
     * 重设联盟折扣
     */
    public void setCommissionAgain() {
        System.out.println("开始重新添加联盟折扣 情况1 将 联盟折扣设置异常 的处理（"+new Date()+")");
        remoteAutoPublishProductService.setCommissionAgainOne();
        System.out.println("结束重新添加联盟折扣 情况1 将 联盟折扣设置异常 的处理（"+new Date()+")");
    }


    /**
     * 自动化上架计划重建
     */
    public void runNotCreatePulishProductProjectJob() {
        System.out.println("开始自动化上架计划重建（"+new Date()+")");
        remoteAutoPublishProductService.runNotCreatePulishProductProjectJob();
        System.out.println("结束自动化上架计划重建（"+new Date()+")");
    }


    /**
     * 调用爬虫创建活动
     */
    public void processingProjectGroupAndDiscount() {
        System.out.println("开始自动化上架计划重建（"+new Date()+")");
        remoteAutoPublishProductService.processingProjectGroupAndDiscount();
        System.out.println("结束自动化上架计划重建（"+new Date()+")");
    }


}
